<!DOCTYPE html>
<html>

<%- include("head.ejs", {title: title}) %>

<body>

	<div>
		<%- include("header.ejs", {title: title}) %>
	</div>
	<!-- <div class="mb40">
		<div class="swiper">
			<div class="swiper-wrapper">
				<div class="swiper-slide blue-slide">
					<img src="/images/header.png" alt="">
				</div>
			</div>
		</div>

	</div> -->
	<div class="gd-main mb60 clearfix">

		<ul class="new-list">

			<%for(var i=0; i < newsList.length; i++){%>
				<li onclick="viewDetail('<%- newsList[i].id%>')" class="new-item">
					<div class="pic">
						<img src="<%- newsList[i].src%>">
					</div>
					<div class="new-content">
						<h3><%=newsList[i].name%></h3>
						<p class="text"><%=newsList[i].content%></p>
						<p class="time"><%=newsList[i].time%></p>
					</div>
				</li>
			<%}%>
			</li>
		</ul>
		

		


		<!--分页-->
	<nav aria-label="Page navigation example" style="float: right;" class="pagination-nav">
		<ul class="pagination">
			<!--1）如果总也等于1或者当前页数为一，上一页按钮不可点击-->
			<% if(totalPages == 1 || pageIndex == 1){ %>
				<li class="page-item disabled"><a class="page-link">&laquo;</a></li>
			<% } else { %>
				<li class="page-item"><a class="page-link" href="/news/newslist/<%= parseInt(pageIndex) - 1 %>/<%= pageSize %>">&laquo;</a></li>
			<% } %>
			<!--2）根据总条数循环生成多少个按钮-->
			<% for(var i = 1; i <= totalPages; i++){ %>
				<!-- 3）根据后台返回的当前第几页，单独处理，设置样式-->
				<% if(i == pageIndex){ %>
					<li class="page-item active"><a class="page-link"><%= i %></a></li>
				<% }else{ %>
					<li class="page-item"><a class="page-link" href="/news/newslist/<%= i %>/<%= pageSize %>"><%= i %></a></li>
				<% } %>
			<% } %>
			<!--4）如果总也等于1或者当前页数等于总页数，下一页按钮不可点击-->
			<% if(totalPages == 1 || pageIndex == totalPages){ %>
				<li class="page-item disabled"><a class="page-link">&raquo;</a></li>
			<% } else { %>
				<li class="page-item"><a class="page-link" href="/news/newslist/<%= parseInt(pageIndex) + 1 %>/<%= pageSize %>">&raquo;</a></li>
			<% } %>
		</ul>
	</nav>
		
	</div>

	

	<div>
		<%- include("footer.ejs") %>
	</div>

	<script>
		var mySwiper = new Swiper('.swiper', {
			watchOverflow: true,//因为仅有1个slide，swiper无效
			navigation: {
				nextEl: '.swiper-button-next',//自动隐藏
				prevEl: '.swiper-button-prev',//自动隐藏
			},
			pagination: {
				el: '.swiper-pagination',//自动隐藏
			},
			scrollbar: {
				el: '.swiper-scrollbar',//自动隐藏
			},
		})
		$(document).ready(function () {
			
				
		})
		function viewDetail(id){
			window.location.href = "/news/newspage?id="+id;
		}
	</script>

</body>

</html>